package top.dancun.easteacher.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.dancun.common.utils.PageUtils;
import top.dancun.common.utils.R;
import top.dancun.easteacher.entity.TeacherStyleEntity;
import top.dancun.easteacher.service.TeacherStyleService;

import java.util.Arrays;
import java.util.Map;


/**
 * 教师风采表
 *
 * @author dancun
 * @email message@dancun.top
 * @date 2022-11-05 10:17:22
 */
@RestController
@RequestMapping("/teacherstyle")
public class TeacherStyleController extends AbstractController{
    @Autowired
    private TeacherStyleService teacherStyleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestBody Map<String, Object> params){
        PageUtils page = teacherStyleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("easteacher:teacherstyle:info")
    public R info(@PathVariable("id") Long id){
		TeacherStyleEntity teacherStyle = teacherStyleService.getById(id);

        return R.ok().put("teacherStyle", teacherStyle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("easteacher:teacherstyle:save")
    public R save(@RequestBody TeacherStyleEntity teacherStyle){
		teacherStyleService.save(teacherStyle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("easteacher:teacherstyle:update")
    public R update(@RequestBody TeacherStyleEntity teacherStyle){
		teacherStyleService.updateById(teacherStyle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("easteacher:teacherstyle:delete")
    public R delete(@RequestBody Long[] ids){
		teacherStyleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
